package cn.wolfcode.dubbo.controller;

import cn.wolfcode.dubbo.product.domian.Product;
import cn.wolfcode.dubbo.product.service.IProductService;
import org.apache.dubbo.config.annotation.Reference;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/products")
public class ProductController {
    //消费者则必须明确告知引用哪个版本的服务,"*"表示随机选用
    @Reference(version = "*")
    private IProductService productService;

    @RequestMapping("/{productId}/{userId}")
    public Product get(@PathVariable Long productId, @PathVariable Long userId) {
        return productService.getProductById(productId, userId);
    }
}
